package top.ochiamalu.aioj.converter;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import top.ochiamalu.aioj.domain.dto.question.AddQuestionDTO;
import top.ochiamalu.aioj.domain.dto.question.UpdateQuestionDTO;
import top.ochiamalu.aioj.domain.entity.Question;
import top.ochiamalu.aioj.domain.vo.question.HotQuestionVO;
import top.ochiamalu.aioj.domain.vo.question.QuestionVO;
import top.ochiamalu.aioj.domain.vo.question.RecentUpdateQuestionVO;
import top.ochiamalu.aioj.domain.vo.question.UpdateQuestionVO;

import java.util.List;

/**
 * 问题转换器
 *
 * @author OchiaMalu
 * @date 2024/12/11
 */
@Mapper
public interface QuestionConverter {
    QuestionConverter INSTANCE = Mappers.getMapper(QuestionConverter.class);

    /**
     * 转换dto到实体
     *
     * @param addQuestionDTO 添加问题dto
     * @return {@link Question }
     */
    @Mapping(target = "tags", ignore = true)
    Question convertDTO2Entity(AddQuestionDTO addQuestionDTO);

    /**
     * 转换实体到vo
     *
     * @param question 问题
     * @return {@link QuestionVO }
     */
    @Mapping(target = "tagList", ignore = true)
    QuestionVO convertEntity2VO(Question question);

    /**
     * 转换实体到更新vo
     *
     * @param question 问题
     * @return {@link UpdateQuestionVO }
     */
    @Mapping(target = "tagList", ignore = true)
    UpdateQuestionVO convertEntity2UpdateVO(Question question);

    /**
     * 转换更新dto到实体
     *
     * @param updateQuestionDTO 更新问题dto
     * @return {@link Question }
     */
    @Mapping(target = "tags", ignore = true)
    Question convertUpdateDTO2Entity(UpdateQuestionDTO updateQuestionDTO);

    /**
     * 转换list到热门题目list
     *
     * @param questionList 题目列表
     * @return {@link List }<{@link HotQuestionVO }>
     */
    List<HotQuestionVO> convertList2HotQuestionVOList(List<Question> questionList);

    /**
     * 转换list到最近更新题目list
     *
     * @param questionList 题目列表
     * @return {@link List }<{@link RecentUpdateQuestionVO }>
     */
    List<RecentUpdateQuestionVO> convertList2RecentUpdateQuestionVOList(List<Question> questionList);
}
